package com.itheima.tlias.common.result;

import lombok.Data;

@Data
public class Result {

    private Result(){}
    private Integer code;
    private String msg;
    private Object data;

    /**
     * 默认成功方法
     * @return
     */
    public static Result success(){
        Result result = new Result();
        result.code = 1;
        result.msg = "success";
        return result;
    }

    /**
     * 携带自定义成功信息的返回方法
     * @param msg
     * @return
     */
    public static Result success(String msg) {
        Result result = new Result();
        result.code = 1;
        result.msg = msg;
        return result;
    }

    /**
     *携带数据的成功方法
     * @param data
     * @return
     */
    public static Result success(String msg,Object data) {
        Result result = new Result();
        result.code = 1;
        result.msg = msg;
        result.data = data;
        return result;
    }
    public static Result success(Object data) {
        Result result = new Result();
        result.code = 1;
        result.msg = "success";
        result.data = data;
        return result;
    }
    public static Result error(String msg) {
        Result result = new Result();
        result.msg = msg;
        result.code = 0;
        return result;
    }
    public static Result error(String msg,Object object) {
        Result result = new Result();
        result.msg = msg;
        result.code = 0;
        result.data = object;
        return result;
    }

}
